//
//  ActivityDetailViewController.m
//  DoubanDemo1
//
//  Created by lanou3g on 15/11/21.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "ActivityDetailViewController.h"
#import "ActivityDetailView.h"
#import "ActivityList.h"
#import "ActivityListHandle.h"
@interface ActivityDetailViewController ()



@end

@implementation ActivityDetailViewController

- (void)loadView
{
    self.activityDetailView = [[ActivityDetailView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.view = self.activityDetailView;
    self.title = @"活动详情";
    
    
    
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //传值
    //标题
    self.activityDetailView.titleLabel.text = self.activityList.title;
    //起止时间
    //拼接字符串
    NSString *timeStr = [NSString stringWithFormat:@"%@ %@",self.activityList.begin_time,self.activityList.end_time];
    self.activityDetailView.timeILView.rightLabel.adjustsFontSizeToFitWidth = YES;
    self.activityDetailView.timeILView.rightLabel.numberOfLines = 0;
    self.activityDetailView.timeILView.rightLabel.text = timeStr;
    //活动举办方
    
   
    self.activityDetailView.sponsorILView.rightLabel.text = self.activityList.name;
//    NSLog(@"%@",self.activityList.name);
    //类型
    
    self.activityDetailView.activityFormILView.rightLabel.text = [NSString stringWithFormat:@"类型： %@",self.activityList.category_name];
    
    //地址
    self.activityDetailView.addressLabel.text = self.activityList.address;
    self.activityDetailView.addressLabel.numberOfLines = 0;
    //活动介绍
    self.activityDetailView.activityIntroduceLabel.text = @"活动介绍";
    //内容
    self.activityDetailView.activityContentLabel.text = self.activityList.content;
    self.activityDetailView.activityContentLabel.numberOfLines = 0;
    
    //活动图片
    NSURL *imageUrl = [NSURL URLWithString:self.activityList.image];
    NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
    self.activityDetailView.activityImageView.image = [UIImage imageWithData:imageData];
    
    
    //左侧返回按钮
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeSystem];
    leftButton.frame = CGRectMake(0, 0, 30, 20);
    [leftButton setBackgroundImage:[UIImage imageNamed:@"btn_nav_back"] forState:UIControlStateNormal];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = leftItem;
    [leftButton addTarget:self action:@selector(leftButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    //右侧收藏按钮
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeSystem];
    rightButton.frame = CGRectMake(0, 0, 30, 30);
    [rightButton setBackgroundImage:[UIImage imageNamed:@"btn_nav_share"] forState:UIControlStateNormal];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem = rightItem;
    [rightButton addTarget:self action:@selector(rightButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    
}
//左侧返回按钮方法
- (void)leftButtonAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma warnning - 右侧收藏按钮方法
//右侧收藏按钮方法
- (void)rightButtonAction:(UIButton *)sender
{
    //self.activityDetailView.titleLabel.text = self.activityList.title;
    NSLog(@"%@",self.activityList.title);
    NSLog(@"%@",self.activityDetailView.titleLabel.text);
}







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
